﻿using System;
using System.Collections.Generic;
using HiTeachers.Data.Manager;
using HiTeachers.Entities;
using HiTeachers.Interfaces;

namespace HiTeachers.Services
{
    public class StaticPageServices
    {
        //private static readonly IStaticPageDao StaticPageDao = NHibernateDaoFactory.Instance.GetDao<IStaticPageDao>("staticPage");
        private static readonly IStaticPageDao StaticPageDao = NHibernateDaoFactory.Instance.GetStaticPageDao();

        public static StaticPage GetById(Guid id)
        {
            return StaticPageDao.GetById(id, false);
        }

        public static StaticPage SaveOrUpdate(StaticPage staticPage)
        {
            return Guid.Empty.Equals(staticPage.ID) ? StaticPageDao.Save(staticPage) : StaticPageDao.SaveOrUpdate(staticPage);
        }

        public static void Delete(StaticPage staticPage)
        {
            StaticPageDao.Delete(staticPage);
        }

        public static StaticPage GetRule()
        {
            return StaticPageDao.GetRule();
        }

        public static StaticPage GetIntroduce()
        {
            return StaticPageDao.GetIntroduct();
        }

        public static int TotalPage(ContentType contentType)
        {
            return StaticPageDao.TotalPage(contentType);
        }

        public static IList<StaticPage> GetStaticPage(ContentType contentType)
        {
            return StaticPageDao.GetStaticPages(contentType);
        }

        #region Guides
        public static int TotalOfGuide()
        {
            return StaticPageDao.TotalPage(ContentType.Guids);
        }

        public static IList<StaticPage> GetGuides()
        {
            return StaticPageDao.GetStaticPages(ContentType.Guids);
        }

        public static IList<StaticPage> GetGuides(int maximumRows, int startRowIndex)
        {
            return StaticPageDao.GetStaticPages(ContentType.Guids, maximumRows, startRowIndex);
        }
        #endregion

        #region FAQs
        public static int TotalOfFaq()
        {
            return StaticPageDao.TotalPage(ContentType.FaQs);
        }

        public static IList<StaticPage> GetFaqs()
        {
            return StaticPageDao.GetStaticPages(ContentType.FaQs);
        }

        public static IList<StaticPage> GetFaqs(int maximumRows, int startRowIndex)
        {
            return StaticPageDao.GetStaticPages(ContentType.FaQs, maximumRows, startRowIndex);
        }
        #endregion

        public static void DeleteDataItem(Guid ID)
        {
            StaticPage staticPage = StaticPageDao.GetById(ID, false);
            StaticPageDao.Delete(staticPage);
        }
    }
}
